package chapter8;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * 使用lambda表达式对集合进行排序和替换
 */
public class ListTest3 {
    public static void main(String[] args) {
        List books = new ArrayList();
        books.add("轻量级Java EE企业应用实战");
        books.add("疯狂Java讲义");
        books.add("疯狂Android讲义");
        books.add("疯狂iOS讲义");
        books.sort((Comparator.comparingInt(o -> ((String) o).length())));
        System.out.println(books);
        books.replaceAll(ele-> ((String)ele).length());
        System.out.println(books);
    }
}
